package game;

import game.Card.Suit;
import game.Card.Value;

public class Card {
	public enum Suit{
		SPADES, HEARTS,CLUBS,DIAMONDS;
	}
	public enum Value{
		ACE(14), TWO(2), THREE(3), FOUR(4), FIVE(5), SIX(6), SEVEN(7), EIGHT(8), NINE(9), TEN(10), JACK(11), QUEEN(12), KING(13);
		private int value;
		private Value(int val){
			value = val;
		}
		public int value() {
			return value;
		}
		public static Value cardWithInt(int i) {
			for (Value v : values()){
				if (v.value == i){
					return v;
				}
			}
			return null;
		}
	}
	private Suit suit;
	private Value value;
	public Card(Suit s, Value v){
		suit = s;
		value = v;
	}
	public Card(String cardRep) {
		String[] parts = cardRep.split(",");
		suit = Suit.valueOf(parts[0]);
		value = Value.valueOf(parts[1]);
	}
	@Override
	public String toString(){
		return suit+","+value;
	}
	@Override
	public boolean equals(Object o){
		return toString().equals(o.toString());
	}
	public Suit getSuit() {
		return suit;
	}
	public Value getValue() {
		return value;
	}
}
